<?php
@session_start();
include_once("../settings.php");
include_once INCLUDE_PATH."host_conf.php";
include_once INCLUDE_PATH."mysql.lib.php";
include_once INCLUDE_PATH."common_functions.php";
die(print_r($_POST));
$connection=mysql_connect(C_DB_HOST, C_DB_USER, C_DB_PASS);
	mysql_select_db(C_DB_NAME,$connection);

if($_POST['funcName']=='loginEvent')
{
	$sql_new = "select * from bb_members where (members_nickname = '".sanitize($_POST["username"])."' || members_email = '".sanitize($_POST["username"])."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());	
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='1'";
		
	
	if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id=''";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}

} /*else if($_POST['funcName']=='loginEventSmall')
{
	
	
	
	
	$sql_new = "select * from bb_members where (members_nickname = '".post("username")."' || members_email = '".post("username")."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		$parentId = $_POST['parentId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='1',comment_parent_id=".$parentId;
		
	
		if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id='".$parentId."'";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">Comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}


	
	
}



else if($_POST['funcName']=='loginGallery')
{
	
	
	$sql_new = "select * from bb_members where (members_nickname = '".post("username")."' || members_email = '".post("username")."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='2'";
		
	
		if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id=''";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}

} 
else if($_POST['funcName']=='loginPhoto')
{
	
	$sql_new = "select * from bb_members where (members_nickname = '".post("username")."' || members_email = '".post("username")."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='3'";
		
	
		if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id=''";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}


	
}else if($_POST['funcName']=='loginBabes')
{
	
	
	$sql_new = "select * from bb_members where (members_nickname = '".post("username")."' || members_email = '".post("username")."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='4'";
		
	
		if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id=''";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}

} else if($_POST['funcName']=='loginChatter'){
	$sql_new = "select * from bb_members where (members_nickname = '".post("username")."' || members_email = '".post("username")."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='5'";
		
	
		if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id=''";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}
}else if($_POST['funcName']=='loginSport'){
	$sql_new = "select * from bb_members where (members_nickname = '".post("username")."' || members_email = '".post("username")."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='6'";
		
	
		if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id=''";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}
}else if($_POST['funcName']=='loginCompetition'){
	$sql_new = "select * from bb_members where (members_nickname = '".post("username")."' || members_email = '".post("username")."') && members_passwd = '".md5_hash($_POST["password"])."' && `members_status` = '1'";
	$res=mysql_query($sql_new)or die(mysql_error());
		
	if(mysql_num_rows($res)>'0')
	{
		$row=mysql_fetch_array($res);
		
		$_SESSION["members_nickname"]=$row["members_nickname"];
		$_SESSION["members_acode"]=$row["members_acode"];
		$_SESSION["members_id"]=$row["members_id"];	
		
	
		$userId=$_SESSION["members_id"];
		$comment= $_POST['comment'];
		$date=date('Y-m-d H:i:s');
		$eventId = $_POST['eventId'];
		$comment_typeId = $_POST['comment_typeId'];
		
		 $sql="insert into bb_comments set comment_ItemId=".$eventId.",comment_by_member_id=".$userId.",comment_text='".$comment."',comment_datetme='".$date."',comment_typeId='".$comment_typeId."'";
		
	
		if(mysql_query($sql))
	{	
		
	 	$sql="select * from bb_comments where comment_ItemId=".$eventId." and comment_parent_id=''";
		$res = mysql_query($sql);
			while($data=mysql_fetch_array($res))
			{
				
   $message.='<div class="clear"></div>';
	 $message.=' <div class="buzz_comment">
	 <div class="profile_img">'.getUserImage($data['comment_by_member_id']).'</div>
        <div class="view_comment">
			<div class="post_comment">
		<span class="profile_name">'.getUserNickName($data['comment_by_member_id']).'</span>'.$data['comment_text'].'<br><span class="postdate">Posted'.$data['comment_datetme'].'</span>';
		
		  if($_SESSION['members_id']==$data['comment_by_member_id'] ) {
			   $message.='- <span  class="cmmt"><a href="javascript:;" onclick="checksubconfirm('.$data_child['comment_id'].','.$data['comment_id'].');"> Delete </a></span>';
			   }
		$message.='-<span class="cmmt"> <a href="javascript:;" onclick="showSmall('.$data['comment_id'].');">comment</a></span></div></div>';
     
	$message.='</div>';
	
			
			}
 
				
	echo $message;	
		}
	}
	else 
	{
		echo "no";	
		
	}
}*/